#pragma once
#include "tool.h"
#include <unordered_map>
#include <sstream>

namespace cloud {
	class dataManager
	{
	private:
		std::string _file_backup;
		std::unordered_map<std::string, std::string> _table;

	public:
		dataManager(const std::string& file_backup)
			:_file_backup(file_backup)
		{
			init();
		}

		void setFile() {
			std::stringstream ss;
			for (auto& it : _table) {
				ss << it.first << " " << it.second << "\n";
			}
			FileTool ft(_file_backup);
			ft.setContent(ss.str());
		}

		void split(const std::string& s, const std::string& sep, std::vector<std::string>* array) {
			size_t pos = 0, start = 0;
			while (true) {
				pos = s.find(sep, start);
				if (pos == std::string::npos)
					break;

				array->push_back(s.substr(start, pos - start));
				start = pos + sep.size();
			}
			if (start < s.size()) {
				array->push_back(s.substr(start));
			}
		}

		void init() {

		}
	};
}